import {WL} from "./weilapb";
import {BuildWeilaMsg} from "./weilapb_wrapper";
import Long from "long";
import {WLBuildMsgRet} from "./weilapb_wrapper_data";

class WeilaPbBusinessWrapper {
    public static buildCommonGetSessionsReq(sessionIds: Long[]): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonGetSessions = new WL.Business.ReqCommonGetSessions();
        businessMessage.reqCommonGetSessions.sessionIds = sessionIds;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_GET_SESSION,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCommonStaffInviteReq(serviceId: number, userIds: number[], content?: string): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonStaffInvite = new WL.Business.ReqCommonStaffInvite();
        businessMessage.reqCommonStaffInvite.userIds = userIds;
        businessMessage.reqCommonStaffInvite.serviceId = serviceId;
        businessMessage.reqCommonStaffInvite.content = content;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_STAFF_INVITE,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCommonAnswerStaffInviteReq(serviceId: number, invitorId: number, status: number): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonAnswerStaffInvite = new WL.Business.ReqCommonAnswerStaffInvite();
        businessMessage.reqCommonAnswerStaffInvite.serviceId = serviceId;
        businessMessage.reqCommonAnswerStaffInvite.invitorId = invitorId;
        businessMessage.reqCommonAnswerStaffInvite.status = status;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_ANSWER_STAFF_INVITE,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCommonGetStaffInviteReq(latestUpdated: number): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonGetStaffInvite = new WL.Business.ReqCommonGetStaffInvite();
        businessMessage.reqCommonGetStaffInvite.latestUpdated = Long.fromValue(latestUpdated);
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_GET_STAFF_INVITE,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCommonStaffExitReq(serviceId: number): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonStaffExit = new WL.Business.ReqCommonStaffExit();
        businessMessage.reqCommonStaffExit.serviceId = serviceId;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_STAFF_EXIT,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCommonStaffDeleteReq(serviceId: number, userId: number): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCommonStaffDelete = new WL.Business.ReqCommonStaffDelete();
        businessMessage.reqCommonStaffDelete.serviceId = serviceId;
        businessMessage.reqCommonStaffDelete.userId = userId;
        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_COMMON_STAFF_DELETE,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }


    //客户接口
    public static buildCustomerCloseSessionReq(sessionId: Long): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCustomerCloseSession = new WL.Business.ReqCustomerCloseSession();
        businessMessage.reqCustomerCloseSession.sessionId = sessionId;

        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_CUSTOMER_CLOSE_SESSION,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }

    public static buildCustomerActiveSessionReq(sessionId: Long, content: string): WLBuildMsgRet {
        const businessMessage = new WL.Business.BusinessMessage();
        businessMessage.reqCustomerActiveSession = new WL.Business.ReqCustomerActiveSession();
        businessMessage.reqCustomerActiveSession.sessionId = sessionId;
        businessMessage.reqCustomerActiveSession.content = content;

        return BuildWeilaMsg.buildWeilaMsgReq(WL.Service.ServiceID.SERVICE_BUSINESS,
            WL.Business.BusinessCommandId.BUSINESS_COMMAND_CUSTOMER_ACTIVE_SESSION,
            WL.Service.CommandType.COMMAND_REQUEST, businessMessage);
    }
}


export {WeilaPbBusinessWrapper}
